home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 4.2 KB | 92 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWLocMap.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWARCHIV_H
- #include "FWArchiv.h"
- #endif
-
- //========================================================================================
- // Any DLL that declares dynamically archivable classes must have its own local copies
- // of two FW_CDynamicArchiver maps. This .cpp file declares storage for these local maps.
- // The compile output (.obj) of this file must be *statically* linked into *each* DLL
- // that declares archivable classes. Also, the application .exe must call
- // MergeArchiverMaps for each DLL. To accomplish this last task, it is necessary
- // to create a uniquely named function for each DLL that simply calls
- // MergeArchiverMaps. The .exe then calls all of these uniquely named functions.
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // FW_CDynamicArchiver Local maps
- //
- // These maps cannot be a static objects, because we must guarantee
- // that they are initialized before any FW_CDynamicArchiver is initialized.
- // We achieve this by using the accessor functions below. The first time the
- // accessor function is called, the corresponding data structure is initialized.
- //
- //----------------------------------------------------------------------------------------
-
- FW_CDynamicArchiver::MapNameToLabel * FW_CDynamicArchiver::gLocalMapClassNameToClassLabel = 0;
- FW_CDynamicArchiver::MapLabelToIOFunction * FW_CDynamicArchiver::gLocalMapClassLabelToObjectIOFunction = 0;
-
- //----------------------------------------------------------------------------------------
- // FW_CDynamicArchiver::GetLocalMapNameToLabel
- //----------------------------------------------------------------------------------------
-
- FW_CDynamicArchiver::MapNameToLabel& FW_CDynamicArchiver::GetLocalMapNameToLabel()
- {
- if (gLocalMapClassNameToClassLabel == 0)
- {
- gLocalMapClassNameToClassLabel = new MapNameToLabel(HashFunction);
- gLocalMapClassNameToClassLabel->SetChunkSize(kChunkSize);
- }
- return *gLocalMapClassNameToClassLabel;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDynamicArchiver::GetLocalMapLabelToIOFunction
- //----------------------------------------------------------------------------------------
-
- FW_CDynamicArchiver::MapLabelToIOFunction& FW_CDynamicArchiver::GetLocalMapLabelToIOFunction()
- {
- if (gLocalMapClassLabelToObjectIOFunction == 0)
- {
- gLocalMapClassLabelToObjectIOFunction = new MapLabelToIOFunction(HashFunction);
- gLocalMapClassLabelToObjectIOFunction->SetChunkSize(kChunkSize);
- }
- return *gLocalMapClassLabelToObjectIOFunction;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CDynamicArchiver::MergeArchiverMaps
- //
- // This function will work if and only if it is statically linked into *each*
- // DLL that has archivable class infos. Each copy of this function must be
- // called during application initialization (before any objects are read from
- // or written to an archive. Since all copies have the same name, the DLL
- // developer must provide a uniquely named function that calls this function,
- // and then arrange for that function to be statically linked to this function.
- // The application developer can then call the uniquely named, DLL-specific function.
- // Note that for safety, this function should not be exported if the build
- // environment supports that feature (just about all Windows build environments
- // do noexport by default, but FWBuild currently arranges to export all functions).
- //
- //----------------------------------------------------------------------------------------
-
- void FW_CDynamicArchiver::MergeArchiverMaps()
- {
- MergeNameToLabelMaps(FW_CDynamicArchiver::GetLocalMapNameToLabel(),
- FW_CDynamicArchiver::GetMapNameToLabel());
- MergeLabelToIOFunctionMaps(FW_CDynamicArchiver::GetLocalMapLabelToIOFunction(),
- FW_CDynamicArchiver::GetMapLabelToIOFunction());
- }
-
-